<?php

namespace app\admin\model\factor;

use think\Model;


class FactorReview extends Model
{

    // 表名
    protected $name = 'carbon_factor_review';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $type = [
        'createtime' => 'timestamp:Y-m-d H:i:s',
        'updatetime' => 'timestamp:Y-m-d H:i:s',
        'checktime' => 'timestamp:Y-m-d H:i:s',
        'images' => 'array'
    ];

    public function factor()
    {
        return $this->hasOne(CarbonFactor::class, 'id', 'factor_id');
    }

    public function getStatusList()
    {
        return ['0' => '待审','1' => '已通过','2' => '驳回'];
    }

    public function category()
    {
        return $this->hasOne(Category::class,'id','category_id');
    }

    public function getCategoryNameAttr()
    {
        return $this->category()->value('name');
    }

}
